package com.groupmobile.quotes;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import com.groupmobile.quotes.database.DataStatic;
import com.groupmobile.quotes.database.DatabaseQuote;

public class QuotesActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash_screen);
		
		//======================CSDL==================
		// Tạo csdl
		DatabaseQuote db = new DatabaseQuote(this);
		db.openDatabase();
		if(db.isOnCreate()){
			//Thêm dữ liệu static
			DataStatic db_static = new DataStatic(db);
			db_static.iniAuthor();
		}
		db.closeDatabase();
		//======================CSDL==================
		
		
		ImageView ss_loading = (ImageView) findViewById(R.id.ss_loading);
		Animation an = AnimationUtils.loadAnimation(this, R.anim.rotate);
		ss_loading.startAnimation(an);

		Handler handlerDelay = new Handler();
		handlerDelay.postDelayed(new Runnable() {

			public void run() {
				Intent intent = new Intent(QuotesActivity.this,
						MainActivity.class);
				startActivity(intent);
				finish();
			}
		}, 3000);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.dashboard_menu, menu);
		return true;
	}

}
